#include "registwidget.h"
#include "ui_registwidget.h"
#include <QDebug>
#include "mywidgetfactory.h"
#include <QMessageBox>
#include "mytcpproxy.h"

RegistWidget::RegistWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RegistWidget)
{
    ui->setupUi(this);
}

RegistWidget::~RegistWidget()
{
    delete ui;
}

//注册按钮
void RegistWidget::on_pushButton_clicked()
{
    MyTcpProxy::sndReg(ui->lineEdit->text(),ui->lineEdit_2->text());
}

//退出按钮
void RegistWidget::on_pushButton_2_clicked()
{
    this->hide();
    MyWidgetFactory::getLoginWidget()->show();
}

//登录报文回复处理槽函数
void RegistWidget::onMsgRecv(const int &ret, const QString &msg)
{
    if(ret){
        QMessageBox::information(this,"注册","注册成功");
        this->hide();
        MyWidgetFactory::getLoginWidget()->show();
        return;
    }
    QMessageBox::critical(this,"注册","注册失败");
}
